package com.lowcodeai.rag;

import com.lowcodeai.rag.model.Document;
import com.lowcodeai.rag.model.QueryRequest;
import com.lowcodeai.rag.model.QueryResult;
import com.lowcodeai.rag.model.KnowledgeBase;

import java.util.List;

/**
 * RAG引擎接口
 * 负责知识库管理和检索增强生成
 * 
 * @author LowCodeAI
 * @since 1.0.0
 */
public interface RagEngine {
    
    /**
     * 创建知识库
     */
    String createKnowledgeBase(KnowledgeBase knowledgeBase);
    
    /**
     * 删除知识库
     */
    void deleteKnowledgeBase(String knowledgeBaseId);
    
    /**
     * 获取知识库信息
     */
    KnowledgeBase getKnowledgeBase(String knowledgeBaseId);
    
    /**
     * 上传文档到知识库
     */
    String uploadDocument(String knowledgeBaseId, Document document);
    
    /**
     * 批量上传文档
     */
    List<String> batchUploadDocuments(String knowledgeBaseId, List<Document> documents);
    
    /**
     * 删除文档
     */
    void deleteDocument(String knowledgeBaseId, String documentId);
    
    /**
     * 更新文档
     */
    void updateDocument(String knowledgeBaseId, String documentId, Document document);
    
    /**
     * 文档检索
     */
    QueryResult search(String knowledgeBaseId, QueryRequest request);
    
    /**
     * 混合检索（向量+关键词）
     */
    QueryResult hybridSearch(String knowledgeBaseId, QueryRequest request);
    
    /**
     * 获取知识库统计信息
     */
    KnowledgeBaseStats getKnowledgeBaseStats(String knowledgeBaseId);
    
    /**
     * 重建向量索引
     */
    void rebuildIndex(String knowledgeBaseId);
    
    /**
     * 知识库统计信息
     */
    class KnowledgeBaseStats {
        private int documentCount;
        private int chunkCount;
        private long totalSize;
        private String lastUpdateTime;
        
        // getters and setters
        public int getDocumentCount() { return documentCount; }
        public void setDocumentCount(int documentCount) { this.documentCount = documentCount; }
        
        public int getChunkCount() { return chunkCount; }
        public void setChunkCount(int chunkCount) { this.chunkCount = chunkCount; }
        
        public long getTotalSize() { return totalSize; }
        public void setTotalSize(long totalSize) { this.totalSize = totalSize; }
        
        public String getLastUpdateTime() { return lastUpdateTime; }
        public void setLastUpdateTime(String lastUpdateTime) { this.lastUpdateTime = lastUpdateTime; }
    }
} 